import pinia from '@/store'
import { useUserStore } from '@/store/modules/user'
import type { App, DirectiveBinding } from 'vue'

const userStore = useUserStore(pinia)

export const isHasButton = (app: App) => {
  //获取用户信息仓库
  app.directive('has', {
    mounted(el: HTMLElement, binding: DirectiveBinding<string>) {
      if (!userStore.buttons.includes(binding.value)) {
        el.parentNode?.removeChild(el)
      }
    },
  })
}
